function fbLogin() {
  FB.login(function(response) {
    if (response.authResponse) {
      // connected
      $("#connect-form").toggleClass("visible hidden");
      $("#demo-form").toggleClass("visible hidden");
      $("#add-panel").toggleClass("hidden visible");
      window.enableFBChecking=1;
      checkFb();
      checkFbEvery(window.fbCheckInterval);
    } else {
      // cancelled
    }
  }, {scope: 'read_stream, publish_stream'});
}

function fbLogout() {
  FB.logout(function(response) {
    // disconnected
  });
}

window.fbAsyncInit = function() {
  // build the link with the Facebook application
  FB.init({
    appId      : '175238489288096', // App ID
    channelUrl : 'http://www.remiduriez.free.fr/socagora/fb-channel.html', // Channel File
    status     : true, // check login status
    cookie     : true, // enable cookies to allow the server to access the session
    xfbml      : true  // parse XFBML
  });

  // catch the login event
  FB.Event.subscribe('auth.login',
    function(response) {
      console.log("Logged in");
      window.enableFBChecking=1;
    }
  );

  // catch the logout event (happen when the user delete Socagora from his Application)
  FB.Event.subscribe('auth.logout',
    function(response) {
      console.log("Logged out");
      window.enableFBChecking=0;
    }
  );

  // determines whether a user is logged in to Facebook and has authenticated the app
  FB.getLoginStatus(function(response) {
    if (response.status === 'connected') {
      // connected
      console.log("Connected to Facebook");
    } else if (response.status === 'not_authorized') {
      // not_authorized
      console.log("Not authorized");
    } else {
      // not_logged_in
      console.log("Not logged in");
    }
  });
};

// Load the SDK Asynchronously
(function(d){
   var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
   if (d.getElementById(id)) {return;}
   js = d.createElement('script'); js.id = id; js.async = true;
   js.src = "http://connect.facebook.net/en_US/all.js";
   ref.parentNode.insertBefore(js, ref);
 }(document));

$('#u_0_0').css({'display': 'none'});